﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace LiteratureManage.Web.Validators
{
    using FluentValidation;
    using LiteratureManage.Domain.Models;

    public class AuthorValidator : AbstractValidator<Author>
    {
        public AuthorValidator()
        {
            RuleFor(model => model.Name)
                .NotEmpty().WithMessage("作者名称不能为空");

            RuleFor(model => model.Gender)
                .GreaterThanOrEqualTo(0).WithMessage("请选择作者性别");

            RuleFor(model => model.Org)
                .NotEmpty().WithMessage("作者联系单位不能为空");

            RuleFor(model => model.Email)
                .EmailAddress().WithMessage("电子邮件格式错误");
        }
    }
}
